package cn.mandifal.staticpages.service.impl;

import cn.mandifal.staticpages.service.ItemPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * 生成商品 sku 页面的 activemq 监听类
 * @author shun
 */
@Component
public class ItemPageListener implements MessageListener {
    @Autowired
    private ItemPageService itemPageService;
    @Override
    public void onMessage(Message message) {
        TextMessage textMessage= (TextMessage) message;
        try {
            String text = textMessage.getText();
            boolean itemHtml = itemPageService.getItemHtml(Long.parseLong(text));
            System.out.println("---------页面是否生成:"+itemHtml);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
